package com.example.service.Impl;

import com.example.entity.EasybuyProduct;
import com.example.entity.EasybuyProductCategory;
import com.example.mapper.EasybuyProductCategoryMapper;
import com.example.mapper.EasybuyProductMapper;
import com.example.service.EasybuyProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EasybuyProductServiceImpl implements EasybuyProductService {

    @Autowired
    public EasybuyProductMapper easybuyProductMapper;

    @Autowired
    public EasybuyProductCategoryMapper easybuyProductCategoryMapper;
//    List<EasybuyProductCategory> alltype = easybuyProductCategoryMapper.findAlltype(1);
    @Override
    public List<EasybuyProductCategory> query() {
        List<EasybuyProductCategory> alltype = easybuyProductCategoryMapper.findAlltype(1);
        for (EasybuyProductCategory pa:alltype){
            List<EasybuyProductCategory> allid = easybuyProductCategoryMapper.findAllid(pa.getId());
            List<EasybuyProduct> query = easybuyProductMapper.query(pa.getId());
            pa.setListEasyBuy(allid);
            pa.setProduct(query);
        }
        return alltype;
    }

    @Override
    public List<EasybuyProduct> query1(Integer id) {
        return easybuyProductMapper.query(id);
    }

    @Override
    public List<EasybuyProduct> query2(Integer id2) {
        return easybuyProductMapper.query2(id2);
    }

    @Override
    public List<EasybuyProduct> query3(Integer id3) {
        return easybuyProductMapper.query3(id3);
    }

    @Override
    public List<EasybuyProduct> findById(Integer id) {
        return easybuyProductMapper.findById(id);
    }
}
